package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/8/6.
 */
@HttpInlet(Conn.INLET_API_TEAM_INFORMATION)
public class GetApiTeamInfomation extends BaseAsyGet<GetApiTeamInfomation.Info> {

    public String userid;

    public GetApiTeamInfomation(AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");

        if (jsonObject.optInt("code") == 200) {

            Info info = new Info();

            info.code = jsonObject.optString("code");
            info.message = jsonObject.optString("message");
            JSONArray array = jsonObject.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {

                JSONObject o1 = array.optJSONObject(i);
                Data data = new Data();

                data.id = o1.optString("id");
                data.title = o1.optString("title");

                info.dataList.add(data);
            }

            return info;
        }

        return null;

    }

    public static class Info {
        public String code, message;
        public List<Data> dataList = new ArrayList<>();
    }

    public static class Data {

        public String id, title;
    }
}
